<?php
	session_start();

	$username=$_SESSION['username'];

	if($username)
	{
		//echo "you are login";
		//echo "welcome $username";
	}
	else
	{
		echo "you are not logged in";
	}
	$button=$_POST['button'];
	
	if($button)
	{
		$gamename=$_POST['gamename'];
		$gamegenre=$_POST['genre'];
		$productowner=$_POST['productowner'];
		//echo $gamegenre;
		include("connect.php");
		$query=mysql_query("SELECT * FROM gameprofile WHERE gamename='$gamename'");
		$numrows=mysql_num_rows($query);
		
		$querygettemp=mysql_query("SELECT * FROM users WHERE username='$productowner'");
		$numrowstemp=mysql_num_rows($querygettemp);
		
		
		if ($numrowstemp != 0){
		if($numrows == 0){
		
			$time=date("d/m/y : H:i:s", time());
			$q=mysql_query("INSERT INTO `gameprofile` (`gamename`,`genre`,`timecreated`)
					VALUES('$gamename','$gamegenre','$time')");
			$role="Product Owner";
			
			$p=mysql_query("INSERT INTO `userrole` 
					VALUES('$productowner','$role','$gamename')");
			echo "you have registeredddddd";
			
			

			echo "<meta http-equiv=\"refresh\" content=\"1;url=http://localhost/my_project/Software_Engineering%20Project/main/wellness/Login/login_admin.php\">";
		}
		else{
			echo "the name of the game is taken" ;
		}
		
		}
		
		else{
			echo "product owner doesn't have account";
		}
	
	}
?>